<template>
  <a-modal
    title="填写材料"
    v-model="visible"
    centered
    :width="400"
    @ok="saveFill"
    @cancel="onCancel"
  >
    <a-form-model
      :model="form"
    >
      <a-alert type="warning" show-icon message="请务必填写反馈意见，不填则默认核对材料无误"></a-alert>
      <a-form-model-item label="整理后的材料">
        <a-button type="danger" icon="download" @click="download">{{ cfmData.file_name }}</a-button>
      </a-form-model-item>
      <a-form-model-item>
        <a-textarea placeholder="请输入流程所做材料是否正确" v-model="form.notes" :rows="4"></a-textarea>
      </a-form-model-item>
    </a-form-model>
  </a-modal>
</template>

<script>
import { getFill } from '@/api/business'

export default {
  props: {
    fillKey: {
      type: String,
      default: ''
    }
  },
  name: 'ConfirmModal',
  data () {
    return {
      visible: false,
      cfmData: {},
      form: {}
    }
  },
  created () {
    this.getInfo(this.fillKey)
  },
  methods: {
    onCancel () {
      this.visible = false
      this.$emit('cancel', this.visible)
    },
    getInfo (key) {
      const app = this
      getFill(key).then(res => {
        app.cfmData['file_name'] = res.result.mat_file_name
        app.cfmData['file_url'] = res.result.mat_file_url
      }).finally(() => {
        app.visible = true
      })
    },
    download () {
      window.open(this.cfmData['file_url'])
    },
    saveFill () {
      this.$emit('submit', this.form)
    }
  }
}
</script>

<style scoped>

</style>
